<#include "/client/config.ftl"/>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no" />
		<title>患者任务一览</title>
		<link rel="stylesheet" href="${base}/css/bootstrap.min.css" />
		<script type="text/javascript" src="${base}/js/jquery-1.12.0.min.js"></script>
		<link rel="stylesheet" href="${base}/css/common.css" />
	</head>

	<body>
		<div class="container-fluid">
			<#if user?exists>
				<form action="${base}/client/task/queryByUser" id="form">
			<#elseif doctor?exists>
				<form action="${base}/client/task/queryByDoctor" id="form">
			<#elseif assitant?exists>
				<form action="${base}/client/task/queryByAssitant" id="form">
			<#else>
				<form action="${base}/client/task/queryByPharmacist" id="form">
			</#if>
			<select id="status" name="status" class="form-control mar_top">
				<#if user?exists>
					<#if status == 0>
						<option value="0" selected>未完成</option>
					<#else>
						<option value="0">未完成</option>
					</#if>
					<#if status == 2>
						<option value="2" selected>已完成</option>
					<#else>
						<option value="2">已完成</option>
					</#if>
					<#if status == 1>
						<option value="1" selected>过期未完成</option>
					<#else>
						<option value="1">过期未完成</option>
					</#if>
				<#else>
					<!-- 顺序不能改变 -->
					<#if status == 2>
						<option value="2" selected>未批阅</option>
					<#else>
						<option value="2">未批阅</option>
					</#if>
					<#if status == 3>
						<option value="3" selected>已批阅</option>
					<#else>
						<option value="3">已批阅</option>
					</#if>
					<#if status == 0>
						<option value="0" selected>未完成</option>
					<#else>
						<option value="0">未完成</option>
					</#if>
					<#if status == 1>
						<option value="1" selected>过期未完成</option>
					<#else>
						<option value="1">过期未完成</option>
					</#if>
				</#if>
			</select>
			<select id="group" name="groupId" class="form-control mar_top">
				<#list groups as gr>
					<#if gr.id == groupId>
						<option selected value="${gr.id}">${gr.name}</option>
					<#else>
						<option value="${gr.id}">${gr.name}</option>
					</#if>
				</#list>
			</select>
			<div class="hidden_area">
				<input type="hidden" id="current" name="current" value="${current}"/>
				<input type="hidden" id="pages" value="${pages}"/>
			</div>
			</form>
			<ul id="task_list" class="mar_top">
				<#list tasks as ts>
					<#if status == 0>
						<#if user?exists>
							<a href="${base}/client/task/doTask?tsId=${ts.tsId}">
						<#else>
							<a href="">
						</#if>
					<#elseif status == 1>
						<a>
					<#else>
						<a href="${base}/client/task/queryDetail?tsId=${ts.tsId}">
					</#if>
						<li class="list_each">
							<#if user?exists>
								<div class="item">
									<#if ts.tsType == 1>
										<span class="key">疼痛评估</span>
									<#elseif ts.tsType == 2>
										<span class="key">不良反应反馈</span>
									<#elseif ts.tsType == 3>
										<span class="key">依从性评价</span>
									<#elseif ts.tsType == 4>
										<span class="key">健康评估</span>
									<#elseif ts.tsType == 5>
										<span class="key">滴定</span>
									<#else>
										<span class="key">服药提醒</span>
									</#if>
									<span class="value">${ts.strDate}</span>
								</div>
							<#else>
								<#if ts.tsType == 1>
									<p class="title">疼痛评估</p>
								<#elseif ts.tsType == 2>
									<p class="title">不良反应反馈</p>
								<#elseif ts.tsType == 3>
									<p class="title">依从性评价</p>
								<#elseif ts.tsType == 4>
									<p class="title">健康评估</p>
								<#elseif ts.tsType == 5>
									<p class="title">滴定</p>
								<#else>
									<p class="title">服药提醒</p>
								</#if>
								<span class="name">${ts.sikerName}</span>
								<span class="date">${ts.strDate}</span>
							</#if>
						</li>
					</a>
				</#list>
			</ul>
			<ul class="pagination page_right">
  				<li><a href="#" onclick="pageChange(0)">&laquo;</a></li>
  				<li><a href="#" onclick="pageChange(1)">&raquo;</a></li>
			</ul>
		</div>
		<script>
			var sta = $("#status");
			var group = $("#group");
			var current = $("#current");
			var pages = $("#pages");
			var form = $("#form");
			sta.change(function(){
				var groupId = group.val();
				if(groupId != null && groupId > 0){
					current.val("1");
					form.submit();
				}
			});
			group.change(function(){
				var groupId = group.val();
				if(groupId != null && groupId > 0){
					current.val("1");
					form.submit();
				}
			});
			function pageChange(num){
				var total = pages.val();
				var now = current.val();
				if(num == 0){
					if(now == 1){
						alert("当前已经是第一页");
					}else{
						var nowNum = parseInt(now);
						nowNum = nowNum - 1;
						current.val(nowNum);
						form.submit();
					}
				}else{
					if(now == total){
						alert("当前已经是最后一页");
					}else{
						var nowNum = parseInt(now);
						nowNum = nowNum + 1;
						current.val(nowNum);
						form.submit();
					}
				}
			}
		</script>
	</body>

</html>